{extends file="../global.html"}
{block name=body}
<style type="text/css">
	.layui-form-item{ width: 90% }

</style>

	<form class="layui-form" action="{url('run/Goods/insert')}" method="post" enctype="multipart/form-data">
	{if $error}
	 <div class="layui-form-item">
	     <div class="layui-input-block">
	    <p style="color:red;font-size:30px">{$error}</p>
	    </div>
	    
	  </div>
	   
	{else}
    	<p>{$error}</p>
	{/if}
	  <div class="layui-form-item">
	    <label class="layui-form-label">商品名称</label>
	    <div class="layui-input-block">
	      <input type="text" name="goods_name" required  lay-verify="required" placeholder="请输入商品名称" autocomplete="off" class="layui-input" id="test">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">所属品牌</label>
	    <div class="layui-input-block">
	      <select name="type_id" lay-verify="required">

	        <option value=""></option>
	        
	       {foreach $res as $k=>$v}
        		<option value="{$v['type_id']}">{$v['type_name']}</option>
   			{/foreach}
			 
	        
	      </select>
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">商品状态</label>
	    <div class="layui-input-block">
	      <select name="goods_status" lay-verify="required">
	        <option value="0">上架</option>
	        <option value="1">补货中</option>
	      </select>
	    </div>
	  </div>
	  <div class="layui-form-item">
		   <label class="layui-form-label">商品封面图片</label>

		  <input type="file"  class="layui-btn" style="width:10%;background:#6E6266" name="file" id="imgPicker">

		  <img id="preview" width="100"/>
  	</div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">厂商指导价(万)</label>
	    <div class="layui-input-block">
	      <input type="number"  step="0.01" name="goods_price" required  lay-verify="required" placeholder="请输入厂商指导价" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <!-- 日期控件 -->
		 <div class="layui-form-item" >
	    <label class="layui-form-label">款型(年份)</label>
	    <div class="layui-input-block">
	      <input type="text" name="goods_model" required  class="Wdate layui-input" onFocus="WdatePicker({ lang:'zh-cn',dateFmt:'yyyy'})" style="background: #737300;" lay-verify="required" autocomplete="off" placeholder="请选择年份">
	    </div>
	  </div>
	  <!-- 排量 -->
    	<div class="layui-form-item">
	    <label class="layui-form-label">排量(T/L)</label>
	    <div class="layui-input-block">
	      <input type="text" name="goods_describe" required  lay-verify="required" placeholder="请输入车型" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <!-- 配置信息 -->
	    <div class="layui-form-item">
	    <label class="layui-form-label">商品配置信息</label>
	    <div class="layui-input-block">
	      <input type="text" name="goods_car" required  lay-verify="required" placeholder="格式：自动/手动xxx版" autocomplete="off" class="layui-input">
	    </div>
	  </div>

	   <div class="layui-form-item">
	    <label class="layui-form-label">车身结构</label>
	    <div class="layui-input-block">
	      <select name="goods_model_car" lay-verify="required">

	        <option value="微小型车">微小型车</option>
	       
	        <option value="紧凑型车">紧凑型车</option>
	        <option value="中型车">中型车</option>
	        <option value="中大型车">中大型车</option>
	        <option value="SUV">SUV</option>
	        <option value="MPV">MPV</option>
	        <option value="跑车">跑车</option>
	
	        
	      </select>
	    </div>
	  </div>

	  <div class="layui-form-item">
	    <label class="layui-form-label">首付(万)</label>
	    <div class="layui-input-block">
	      <input type="number"  step="0.01" name="goods_payment" required  lay-verify="required" placeholder="请输入首付价格" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	   <div class="layui-form-item">
	    <label class="layui-form-label">月供(元)</label>
	    <div class="layui-input-block">
	      <input type="number" name="goods_month" required  lay-verify="required" placeholder="请输入月供" autocomplete="off" class="layui-input">
	    </div>
	  </div>

	  <div class="layui-form-item">
	    <label class="layui-form-label">尾款购车(元)</label>
	    <div class="layui-input-block">
	      <input type="number" name="goods_retainage" required  lay-verify="required" placeholder="请输入尾款购车" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  
	 <!--   <div class="layui-form-item">
		  <label class="layui-form-label">图册</label>

		  
<input id = "input-b3" name = "input-b3[]" type = "file" class ="file" multiple data-show-upload = "false" data-show-caption = "true" >  
  	 </div> -->
<div class="container-fluid">
<div class="row" style="">
	<label class="form-label col-xs-4 col-sm-2">多图预览上传</label>
	<div class="col-md-6  col-xs-8 col-sm-9">
	<div style="width:935px;height: 277px;overflow: hidden;margin-left: -80px;border: 1px solid #ccc;border-radius: 4px;">
    
	<img src=" "/>

	</div class="col-md-12">
		<input name="goods_pictures[]" id="file-0a" class="file" type="file" multiple data-min-file-count="0" style="width: 769px" />
	</div>
</div>
</div>
 
 <!-- 拼音 -->
 <input type="hidden" name="goods_pinyin" value="" class="">

<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" id="btn" lay-submit lay-filter="formDemo">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</div>
	</form>
	<label><input type="radio" name="pinyin_goods" value="1"/ checked style="display: none;"></label>
	<div id="result"></div>
	  <script type="text/javascript">
	  function getPinyin()
	  {
	    var value = document.getElementById('test').value;
	    var type = document.querySelector('[name="pinyin_goods"]:checked').value;
	    var pinyin = document.querySelector('[name="goods_pinyin"]').checked;
	    var result = '';
	    if(value)
	    {
	      switch(type)
	      {
	        case '1': result = pinyinUtil.getPinyin(value, '', false, pinyin); break;
	        
	      }
	    }
	    $('#test').blur(function(){
	      $.trim($('input[type="hidden"]').val(result));
	    })
	  }
	  document.getElementById('test').addEventListener('input', getPinyin);
	  document.addEventListener('change', function(e)
	  {
	    if(e.target.name === 'pinyin_goods')
	    {
	      getPinyin();
	    }
	  });
	  getPinyin();
	  // 初始化简单的拼音输入法
	  // SimpleInputMethod.init('.test-input-method');

	  </script>

	   

<script type="text/javascript">
pic();
//var ue = UE.getEditor('container');

//初始化fileinput控件（第一次初始化）
$("#file-0").fileinput({
   
        allowedFileExtensions : ['jpg', 'png','gif'],//接收的文件后缀
      
    });
 	
 	var picname = $('input[type="file"]')
        var picval = $('input[type="file"]').val();
        if(picval == ''){
          $('#btn').addClass('layui-btn-disabled');
              $('#btn').attr('onclick','return false');
            }

        picname.change(function(){
          if($(this).val()){
               $('#btn').removeClass('layui-btn-disabled');
              $('#btn').attr('onclick','return true');
          }
        })
	</script>
      

{/block}
 
